home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DDJ0992.ARJ / DBVID.ASM < prev    next >
Assembly Source File  |  1992-05-04  |  15KB  |  349 lines

  1. ;dbvid.asm 
  2. ;Debugger video routines
  3. ;
  4. .386P
  5. ;---------------------------------------------------------------------------- 
  6. ;Copyright 1991, 1992 ASMicro Co. 
  7. ;7/6/91       Rick Knoblaugh
  8. ;-----------------------------------------------------------------------------
  9.                 include dbequ.inc
  10.                 include dbstruc.inc
  11.  
  12. data            segment para public 'data16' use16
  13.                 extrn   save_curs_pos:word
  14.                 extrn   config_attrib:byte 
  15.                 extrn   debug_page:byte                        
  16.                 extrn   wrk_vid_offset:word
  17.                 extrn   user_page:byte
  18.                 extrn   debug_page_off:word
  19.                 extrn   prompt_char:byte
  20. data            ends
  21.  
  22. zcode            segment para public 'code16' use16
  23.  
  24.                 public  prt_err_msg, prt_string, scroll_cmds_up, scroll_up              
  25.                 public  set_video_page, set_cursor_pos, calc_offset     
  26.                 public  prt_prompt, get_cursor_pos          
  27.                 public  clear_window                    
  28.  
  29.     assume cs:zcode, ds:data, es:nothing
  30.  
  31. ;----------------------------------------------------------------------
  32. ; prt_err_msg - scroll window and print error message.                |
  33. ;                                                                     |
  34. ;             Enter: si = offset of error message.                    |
  35. ;                                                                     |
  36. ;              Exit: Carry flag set as many callers would also do     |
  37. ;                    this.                                            |
  38. ;----------------------------------------------------------------------
  39. prt_err_msg     proc    near
  40.                 mov     di, wrk_vid_offset              ;prompt location
  41.                 add     di, 2                           ;just after prompt
  42.                 mov     ah, config_attrib
  43.                 call    prt_string
  44.                 call    scroll_cmds_up
  45.                 stc
  46.                 ret
  47. prt_err_msg     endp
  48.  
  49. ;----------------------------------------------------------------------
  50. ; prt_string - display string on screen.                              |
  51. ;                                                                     |
  52. ;             Enter: si = offset of string (STR_TERM terminated)      |
  53. ;                    es = video segment                               |
  54. ;                    di = offset into video buffer for display        |
  55. ;                    ah = attribute to be used for display.           |
  56. ;                                                                     |
  57. ;----------------------------------------------------------------------
  58.  
  59. prt_char:
  60.                 stosw
  61.  
  62. prt_string      proc    near
  63.                 lodsb
  64.                 cmp     al, STR_TERM
  65.                 jne     short prt_char
  66.                 ret
  67. prt_string      endp
  68.  
  69.  
  70. ;----------------------------------------------------------------------
  71. ; scroll_cmds_up - scroll command area up 1 line.                     |
  72. ;                                                                     |
  73. ;            Enter:             es = segment of video buffer.         |
  74. ;                   wrk_vid_offset = offset of prompt in video buffer.|
  75. ;                                                                     |
  76. ;             Exit:             di = offset of next location past     |
  77. ;                                    prompt char in video buffer.     |
  78. ;                                                                     |
  79. ;             ax, cx, dx, si saved.                                   |
  80. ;----------------------------------------------------------------------
  81. scroll_cmds_up  proc    near
  82.                 push    ax
  83.                 push    cx
  84.                 push    dx
  85.                 push    si
  86.                 mov     si, debug_page_off
  87.                 add     si, (DEBUG_COL * 2) + 2
  88.                 mov     cx, DEBUG_ROW           ;number of rows
  89.                 mov     dx, CMD_MAX_LEN         ;number of columns
  90.                 mov     ah, config_attrib       ;attribute for bottom line
  91.                 mov     al, ' '                 ;fill char for bottom line
  92.                 call    scroll_up
  93.                 mov     di, wrk_vid_offset      ;get prompt location
  94.                 add     di, 2                   ;just past prompt
  95.                 pop     si
  96.                 pop     dx
  97.                 pop     cx
  98.                 pop     ax
  99.                 ret
  100. scroll_cmds_up  endp
  101. ;----------------------------------------------------------------------
  102. ; scroll_up - scroll window up 1 line.                                |
  103. ;                                                                     |
  104. ;             Enter: es = segment of video buffer.                    |
  105. ;                    si = offset of upper left hand corner            |
  106. ;                    cx = number of rows to move up                   |
  107. ;                    dx = number of columns in width                  |
  108. ;                    ax = attribute/char for filling bottom line      |
  109. ;                                                                     |
  110. ;         DS saved.                                                   |
  111. ;                                                                     |
  112. ;----------------------------------------------------------------------
  113. scroll_up       proc    near
  114.                 jcxz    short scroll_up999      ;if none to scroll
  115.                 push    ds
  116.  
  117.                 push    es
  118.                 pop     ds                      ;ds=es=video
  119. scroll_up100:
  120.                 push    cx
  121.                 mov     di, si
  122.                 add     si, 160                 ;next line up
  123.                 push    si
  124.                 mov     cx, dx
  125.                 rep     movsw
  126.                 pop     si
  127.                 pop     cx
  128.                 loop    scroll_up100
  129.                 mov     cx, dx
  130.                 mov     di, si
  131.                 rep     stosw
  132.                 pop     ds
  133.  
  134. scroll_up999:
  135.                 ret
  136. scroll_up       endp
  137.  
  138. ;----------------------------------------------------------------------
  139. ;set_video_page - Make video page active.                             |
  140. ;                                                                     |
  141. ;             Enter: bl = page to make active                         |
  142. ;             All registers saved.                                    |
  143. ;----------------------------------------------------------------------
  144. set_video_page  proc    near
  145.                 push    ax
  146.                 push    bx
  147.                 push    dx
  148.                 push    es
  149.                 mov     al, bl
  150.                 cbw
  151.                 mov     dx, PAGE_SIZE/2 ;page size in words
  152.                 mul     dx
  153.                 push    ax              ;save page offset in words
  154.  
  155.                 mov     dx, 40h         ;bios data area
  156.                 mov     es, dx
  157.                 mov     dx, es:[ADDR_6845]      ;get address register
  158.                 mov     al, 0ch         ;start address high
  159.                 out     dx, al
  160.  
  161.                 inc     dx              ;data register
  162.                 xchg    al, ah          ;get high portion into al
  163.                 out     dx, al          ;write it out
  164.                 dec     dx              ;back to address register
  165.                 mov     al, 0dh         ;start address low
  166.                 out     dx, al
  167.                 inc     dx              ;data register
  168.                 pop     ax              ;restore offset in words
  169.                 out     dx, al          ;write it out
  170.  
  171.                 pop     es
  172.                 pop     dx
  173.                 pop     bx
  174.                 pop     ax
  175.                 ret
  176. set_video_page  endp
  177.  
  178. ;----------------------------------------------------------------------
  179. ;set_cursor_pos - Program hardware directly to set cursor position.   |
  180. ;                                                                     |
  181. ;                 Enter:  ax = video offset in words                  |
  182. ;                                                                     |
  183. ;----------------------------------------------------------------------
  184. set_cursor_pos     proc  near
  185.                 push    ax
  186.                 push    cx
  187.                 push    dx
  188.                 push    es
  189.                 mov     cl, al          ;save low portion
  190.  
  191.                 mov     dx, 40h         ;bios data area
  192.                 mov     es, dx
  193.                 mov     dx, es:[ADDR_6845]      ;get address register
  194.                 
  195.                 mov     al, 0eh         ;cursor location high
  196.                 out     dx, al
  197.                 inc     dx
  198.                 xchg    ah, al
  199.                 out     dx, al          ;write high portion
  200.                 
  201.                 dec     dx
  202.                 mov     al, 0fh         ;cursor location low
  203.                 out     dx, al
  204.                 inc     dx
  205.                 mov     al, cl          ;get low ;portion
  206.                 out     dx, al
  207.                 pop     es
  208.                 pop     dx
  209.                 pop     cx
  210.                 pop     ax
  211.  
  212.                 ret
  213. set_cursor_pos     endp    
  214.  
  215.  
  216. ;----------------------------------------------------------------------
  217. ;calc_offset - calculate offset (in words) into video buffer.         |
  218. ;                                                                     |
  219. ;                 Enter:  bl = video page                             |
  220. ;                         ch = row of cursor position (0-24)          |
  221. ;                         cl = column of cursor position (0-79)       |
  222. ;                                                                     |
  223. ;                 Exit:                                               |
  224. ;                         ax = offset in words                        |
  225. ;----------------------------------------------------------------------
  226. calc_offset     proc    near
  227.                 mov     al, 80          ;words in a line
  228.                 mul     ch
  229.                 sub     ch, ch
  230.                 add     ax, cx
  231.  
  232.                 mov     cx, ax          ;save it
  233.                 sub     bh, bh
  234.                 mov     ax, PAGE_SIZE/2
  235.                 mul     bx
  236.                 add     ax, cx          ;ax=total offset in words
  237.                 ret
  238. calc_offset     endp
  239.  
  240. ;----------------------------------------------------------------------
  241. ;prt_prompt - display prompt character at current buffer offset.      |
  242. ;                                                                     |
  243. ;                 Enter:  es = segment of video buffer                |
  244. ;                         di = video buffer offset                    |
  245. ;                                                                     |
  246. ;                                                                     |
  247. ;                 Exit: di advanced to next buffer position           |
  248. ;                                                                     |
  249. ;----------------------------------------------------------------------
  250. prt_prompt      proc    near
  251.                 mov     al, prompt_char
  252.                 mov     ah, config_attrib
  253.                 stosw
  254.                 ret
  255. prt_prompt      endp        
  256.  
  257.  
  258.   
  259. ;----------------------------------------------------------------------
  260. ;get_cursor_pos - Retrieve cursor position for active video page      |
  261. ;                 from the BIOS data area.                            |
  262. ;                                                                     |
  263. ;                 Exit:                                               |
  264. ;                         ah = row of cursor position (0-24)          |
  265. ;                         al = column of cursor position (0-79)       |
  266. ;                         dl = active page                            |
  267. ;                                                                     |
  268. ;----------------------------------------------------------------------
  269. get_cursor_pos  proc    near
  270.                 push    bx
  271.                 push    ds
  272.                 mov     ax, 40h         ;bios data area
  273.                 mov     ds, ax
  274.                 xor     bx, bx
  275.                 mov     bl, [bx + ACTIVE_PAGE]
  276.                 mov     dl, bl
  277.                 shl     bx, 1           ;index into words
  278.                 mov     ax, [bx + CURSOR_POS]
  279.                 pop     ds
  280.                 pop     bx
  281.                 ret
  282. get_cursor_pos  endp        
  283.  
  284.  
  285.  
  286. ;----------------------------------------------------------------------
  287. ;clear_window - Clear a window with a specified char and attribute.   |
  288. ;                                                                     |
  289. ;                 Enter:  bl = video page                             |
  290. ;                         es = video segment or selector              |
  291. ;                         dx = row, col of upper left hand corner     |
  292. ;                         cx = row, col of lower right hand corner    |
  293. ;                         ax = attribute, char to use                 |
  294. ;                                                                     |
  295. ;                 Exit:                                               |
  296. ;                         all registers saved.                        |
  297. ;                                                                     |
  298. ;----------------------------------------------------------------------
  299. clear_window    proc    near
  300.                 push    bx
  301.                 push    cx
  302.                 push    dx
  303.                 push    di
  304.  
  305.                 push    ax
  306.                 push    dx
  307.                 mov     ax, PAGE_SIZE
  308.                 sub     bh, bh
  309.                 mul     bx              ;compute start of buffer per page
  310.                 pop     dx
  311.                 mov     di, ax
  312.                 mov     al, 160         ;entire row of chars and attributes
  313.                 sub     ch, dh          ;ch=total rows to clear
  314.                 inc     ch
  315.                 mul     dh              ;ax=offset to starting row
  316.                 add     di, ax
  317.                 sub     dh, dh
  318.                 mov     al, dl          ;save starting column
  319.                 shl     dl, 1           ;count attributes also
  320.                 add     di, dx          ;add offset out to starting col
  321.                 sub     cl, al          ;get total columns in width
  322.                 inc     cl
  323.                 sub     dh, dh
  324.                 mov     dl, cl          ;put in dx
  325.                 mov     cl, ch
  326.                 sub     ch, ch
  327.                 pop     ax              ;restore attribute/char
  328.                 mov     bx, di          ;save starting offset for row
  329.                 
  330. clear_w100:
  331.                 push    cx
  332.                 mov     cx, dx          ;width in columns
  333.                 rep     stosw
  334.                 pop     cx              ;row count
  335.                 add     bx, 160         ;offset for next row
  336.                 mov     di, bx
  337.                 loop    clear_w100
  338.  
  339.                 pop     di
  340.                 pop     dx
  341.                 pop     cx
  342.                 pop     bx
  343.                 ret
  344. clear_window    endp        
  345.  
  346. zcode            ends
  347.             end     
  348.  
  349.